#!/usr/bin/python
# -*- coding: utf-8 -*-

'''
Introduction to Programming in Java - An Interdisciplinary Approach

All book programs ported to Python by
Scott C. King (revisionx at {gee}ma1l <dot> c0m).

All program examples pass Pylint with a perfect 10.00 score.
Pylint:  http://www.pylint.org/


Program 1.5.2 - Interactive user input

Syntax:
python twentyquestions.py


Notes:
int(sys.argv[1]) == Integer.parseInt(args[0])

sys is a required import here in order to use command line arguments.
https://docs.python.org/2/tutorial/stdlib.html

random is a required import as a substitute for Java's Math.random()
https://docs.python.org/2/library/random.html

'''

import random


def main():
    ''' implementation of twenty questions guessing game '''

    print "Hello, I'm thinking of a number between 1 and 1,000,000."
    random_num = int(random.random() * 1000000)

    guess = None
    while guess != random_num:
        guess = int(raw_input("What's your guess? "))
        if guess == random_num:
            print 'You win!'
        if guess < random_num:
            print 'Too low!'
        if guess > random_num:
            print 'Too high!'


if __name__ == '__main__':
    main()
